package fy.mdm.operator;

import java.util.ArrayList;
import java.util.List;

import com.seeyon.v3x.services.flow.bean.FlowExport;
import com.seeyon.v3x.services.form.bean.ValueExport;

import fy.form.listen.operate.AForm_Save_Operator;
import fy.form.listen.operate.IFormOperator;
import fy.mdm.bean.FiexdLineBean;

import fy.mdm.dao.FiexdLineReviewDao;

public class FiexdLineFormOperator extends AForm_Save_Operator implements IFormOperator{
	private FiexdLineBean line=new FiexdLineBean();
	private List<String> numberList = new ArrayList<String>();
//	private List<String> lineList = new ArrayList<String>();

	@Override
	public String getFormName() {
		// TODO Auto-generated method stub
		return "固定资产转移单";
	}

	@Override
	protected void parseOtherField_FirstStep(FlowExport flowExport) {

		// TODO Auto-generated method stub
		line.setSummaryId(super.formBean.getSummaryId());
		line.setBillname(flowExport.getFlowTitle());
		line.setApplier(flowExport.getFlowCreatePerson().getName());
		line.setTs(flowExport.getFlowCreateTime());
	}

	@Override
	protected void parseValueExport(ValueExport ve) {

		String fieldName = ve.getDisplayName();
		if ("设备条码".equals(fieldName)) {
			this.numberList.add(ve.getValue());
		}  else if("转入生产线代码".equals(fieldName)){
			line.setNewLineCode(ve.getValue());
		}
		else if ("盘亏报废".equals(fieldName)) {
			line.setAssetstates(ve.getValue());
		}
		// TODO Auto-generated method stub
		
	}

	@Override
	protected boolean save() {

		try {
			line.setNumberList(this.numberList);
//			line.setLineList(this.lineList);
			FiexdLineReviewDao fiexdLineReviewDao = new FiexdLineReviewDao();
			fiexdLineReviewDao.setFiexdLineBean(line);
			

			
			return fiexdLineReviewDao.StateReturn();
			
		} catch (Exception e) {
			e.printStackTrace();
		}finally {
			//bean.clear();
			line = null;
			}
		return success;
	}

}
